package com.tengju.support.application.message;

import com.tengju.support.application.shared.ApplicationException;
import com.tengju.support.application.shared.ApplicationExceptionCode;
import com.tengju.support.domain.model.user.UserId;
import com.tengju.support.domain.service.PushCidBindBaseService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Slf4j
@Service
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class PushCidBindService {

    private final PushCidBindBaseService pushCidBindBaseService;

    public boolean bind(UserId userId, String registerId) {

        if (userId == null || StringUtils.isEmpty(registerId)) {
            throw ApplicationException.error(ApplicationExceptionCode.INVALID_DATA,"用户id或cid为空");
        }

        return pushCidBindBaseService.bind(userId,registerId);

    }

    public boolean unbind(UserId userId) {

        if (userId == null) {
            throw ApplicationException.error(ApplicationExceptionCode.INVALID_DATA,"用户id为空");
        }

        return pushCidBindBaseService.unbind(userId);
    }



}
